<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<style type="text/css">
	.line{border-bottom:3px solid lightgray}
	.border-lavener{
		border: 1px solid #e6e6fa;
	}
	
	.musicContainer{
		max-width: none!important;
		width: 940px;
	}
	
	.titleSection{
		position: relative;
		min-height: 30px;
		border: 1px solid #e6e6fa;
		padding-bottom: 5px;
		padding-top: 5px;
		padding-left: 20px;
		padding-right: 20px;
		margin-top: 5px;
		margin-bottom: 5px;
		background-color: #f5f5f5;
	}
	
	.contentSection{
		height: 420px;	
	}

	.freeContainer:before, .freeContainer:after,
	.titleSection:before, .titleSection:after,
	.contentSection:before, .contentSection:after{
		content: " ";
		display: table;
	}
	:before, :after{
		box-sizing: border-box;
	}
	.freeContainer:after, .titleSection:after,
	.contentSection.after{
		clear: both;
	}
</style>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.1.0.js"></script>
<script type="text/javascript">
var categories = (${initParam.qnaKind}).split(", ");
	$(document).ready(function(){
		if(${sessionScope.mvo.grade=="admin"}){
			$("#kind").append("<option value=\"공지\">공지</option>");
		}
		$.each(categories, function(index, category){
			$("#kind").append("<option value=\"" + category + "\">" + category + "</option>");
		});
		
		
		$("#toWrite").click(function(){
			 if($(":input[name=title]").val()==""){
				alert("제목을 쓰세요.");
				$(":input[name=title]").focus();
				//return false;
			}else if($("textarea[name=content]").val()==""){
				alert("내용을 작성하세요.");
				$("textarea[name=content]").focus();
				//return false;
			}else{
				$("#writeForm").submit();
			}
		});
		$("#cancel").click(function(){
			 /* $("form").each(function() {  
				 if(this.name == "writeForm") 
					 this.reset();  
		     });   */
			location.href="getQnAList.ju";
		});
	});
</script>

</head>
<body>
 <form action="writeQnA.ju" method="post" name="writeForm" id="writeForm">
 <input type="hidden" name="memberVO.id" value="${sessionScope.mvo.id}">
  	
  	<div class="form-group">
      <label for="inputTitle" class="col-lg-2 control-label">제목</label>
      <div class="col-lg-10">
        <input type="text" class="form-control" id="inputTitle" placeholder="Title" name="title">
        <br>
      </div>
    </div>
    
	<div class="form-group">
      <label for="select" class="col-lg-2 control-label">질문 종류</label>
      <div class="col-lg-10">
        <select class="form-control" id="kind" name="kind">
          <option value="">--------</option>
        </select>
        <br>
        <!-- <span class="text-primary">...</span> -->
      </div>
    </div>
    
    <div class="form-group">
      <label for="textArea" class="col-lg-2 control-label">내용</label>
      <div class="col-lg-10">
        <textarea class="form-control" rows="5" id="textArea" name="content" style="resize:none"></textarea>
        <br>
      </div>
    </div>
    
    <div class="form-group">
      <div class="col-lg-10 col-lg-offset-2" align="center">
        <button type="button" class="btn btn-default" id="cancel">취소</button>
        <button type="button" class="btn btn-primary" id="toWrite">등록</button>
        <br><br>
      </div>
    </div>

</form>
</body>
</html>